import cv2
import os
import glob as myy_glob

All_jpg = (myy_glob.glob(r"*.bmp")) + (myy_glob.glob(r"*.jpg")) + (myy_glob.glob(r"*.png"))
print(All_jpg)
for A_jpg in All_jpg:
    img = cv2.imread(A_jpg,1)
    rows,cols,ch = img.shape
    for i in range(rows):
        for j in range(cols):
            for c in range(ch):
                if img[i][j][c] >122:
                    img[i][j][c]=255
                else:
                    img[i][j][c]=0
    A_jpg, _ = A_jpg.split(".")
    cv2.imwrite(A_jpg+'.bmp',img)
